<?php
/* @var $this ContactController */
/* @var $data Contact */
?>

<div class="view">

	<b><?php echo CHtml::encode($data->getAttributeLabel('companyName')); ?>:</b>
	<?php echo CHtml::encode($data->companyName); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('userName')); ?>:</b>
	<?php echo CHtml::encode($data->userName); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('regency')); ?>:</b>
	<?php echo CHtml::encode($data->regency); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('email')); ?>:</b>
	<?php echo CHtml::encode($data->email); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('title')); ?>:</b>
	<?php echo CHtml::encode($data->title); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('fax')); ?>:</b>
	<?php echo CHtml::encode($data->fax); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('address')); ?>:</b>
	<?php echo CHtml::encode($data->address); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('phone')); ?>:</b>
	<?php echo CHtml::encode($data->phone); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('website')); ?>:</b>
	<?php echo CHtml::encode($data->website); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('content')); ?>:</b><br/>
	<?php echo CHtml::encode($data->content); ?>
	<br />
        
        <?php 
        $attachment=$data->attachment;
        if($attachment): ?>
            <b><?php echo CHtml::encode($data->getAttributeLabel('upload')); ?>:</b>
            <?php echo CHtml::link($attachment->name, Yii::app()->baseUrl . '/' . $attachment->url) ?><br/>
        <?php endif ?>

	<b><?php echo CHtml::encode($data->getAttributeLabel('status')); ?>:</b>
	<?php echo $data->status?'Da xem':'Chua xem'; ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('createTime')); ?>:</b>
	<?php echo CHtml::encode($data->createTime); ?>
	<br />
</div>

<?php if($data->status==0){ ?>
<div class="buttons">
    <?php echo CHtml::button('Da Xem', array('id'=>'btnok')) ?>
</div>
<?php } ?>

<script type="text/javascript">
    $(function(){
        $('#btnok').click(function(){
            $.ajax({
                url:'<?php echo Yii::app()->createUrl('admin/contact/markViewed', array('id'=>$data->id)) ?>',
                dataType:'json',
                success:function(data){
                    if(data.success){
                        closeDialog();
                        refreshGrid();
                    }
                }
            });
            
        });
    });
</script>